<template>
	<div class="index">
	    <input type="file" accept="video/*" id="video" name="video" @change="uploadVideo($event)">
	    <!-- <video :src="videoSrc" controls="controls" style="width: 50%;height: 50%"></video> -->
	</div>	
</template>
<script>
export default {
  name: 'index',
  data () {
   	return{
          videoSrc:'',
   	}
  },
  methods:{
    //上传视频转为blob格式
    uploadVideo(e) {
        var that = this;
        var video = event.target.files[0];  //选择的文件
        var reader = new FileReader();  
        var rs =  reader.readAsArrayBuffer(video) 
        reader.onload = (e) => {
          let data;
          if (typeof e.target.result === 'object') {
              data = window.URL.createObjectURL(new Blob([e.target.result]))
          } else {
              data = e.target.result
          }
          // this.videoSrc= data; 
          console.log("视频地址" +data)
          this.$http.post("http://127.0.0.1:5000/upload",{
          	data:data
          }).then(res=>{
          	if(res.data.code==200){
          		alert(res.data.msg)
          	}
          })
        } 
    },
     //上传视频转为based4格式
     //uploadVideo(e) {
        //     var that = this;
        //     var video = event.target.files[0];  //选择的文件
        //     var reader = new FileReader();  
        //     var rs = reader.readAsDataURL(video);  
        //     reader.onload = (e) =>{
        //       var videoSrc= e.target.result; 
        //       this.videoSrc=video
        //       console.log(videoSrc)
        //       //提交到后台部分略
        //     } 
        // }          
  }
}
</script>